package com.ssm.student.service.impl;

import com.ssm.student.dao.PowerMapper;
import com.ssm.student.dao.RoleMapper;
import com.ssm.student.model.Power;
import com.ssm.student.model.Role;
import com.ssm.student.service.PowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PowerServiceImpl implements PowerService {

    @Autowired
    private PowerMapper powerMapper;
    /*
     * 权限添加方式实现
     * @param power 权限实体
     * @return 是否成功（—1：含有重复信息）
     * */


    public int insertPower(Power power) {
        int returnInt=0;
        /*1业务的判断
        （1）权限界面名称不能重复
        */
        //（1）权限界面名称不能重复
        int powerFaceCount=powerMapper.getPowerface(power.getPowerface());
        if (powerFaceCount<2){


            //2数据的添加
            int addPowerInt=powerMapper.insertPower(power);


            //3返回值的设置
            returnInt=addPowerInt;
        }else{
            returnInt=-1;//有相同的权限名称
        }
        return 0;
    }

    @Override
    public int insertPower(PowerService powerService) {
        return 0;
    }
}


